package com.fable.sp.core.widgets;

import com.fable.sp.core.domain.PersistentField;
import com.fable.sp.core.enums.ColumnType;
import com.fable.sp.core.widget.Preference;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

/**
 * .
 *
 * @author stormning on 16/7/26.
 */
@Component
public class SimpleTextarea extends PersistentWidget implements InitializingBean {
    @Override
    public String getTitle() {
        return "大文本输入框";
    }

    @Override
    public String getTags() {
        return "文本输入";
    }

    @Override
    public String getInfo() {
        return "普通大文本";
    }

    @Override
    public String getCover() {
        return "/webjars/widgets/images/textarea.png";
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        Preference validation = new Preference("validation", "校验规则", "no");
        Preference minSize = new Preference("minSize", "最小长度", null);
        Preference maxSize = new Preference("maxSize", "最大长度", null);
        setPreferences(Lists.<Preference>newArrayList(
                new Preference("placeholder", "占位", null), new Preference("height", "高度", null), validation,minSize,maxSize
        ));
    }

    @Override
    public PersistentField defineField() {
        return new PersistentField(ColumnType.STRING);
    }
}
